#include <stdio.h>
 
int binary_serach(int *data, int len, int d)
{
	int l, u, m;

	if (data == NULL || len <= 0)
		return -1;

	l = 0;
	u = len - 1;

	while (l < u) {
		m = l + (m - l) / 2;
		if (data[m] < d)
			l = m + 1;
		else 
			u = m;
	}
	if (data[m] == d)
		return m;
	return -1;
}

int main()
{
	int data[] = {1, 1, 1, 1, 1, 1};
	int pos;

	pos = binary_serach(data, 6, 1);
	printf("pos:%d\n", pos);
	return 0;
}

